package com.cedifie.lendapp.ui.steps.adapter

import android.graphics.Color
import android.graphics.Typeface
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.cedifie.lendapp.R
import com.cedifie.lib_baseadapter.CEDRecyclerViewAdapter
import com.cedifie.lib_baseadapter.CEDViewHolderHelper
import org.json.JSONObject

/**
 * Cedifie
 * @Author wwdeng
 * @CreateTime: 2024/6/18 14:46
 * @Annotation：流程Tab适配器
 */
class CedStepTabAdapter(recyclerView: RecyclerView?) : CEDRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.item_step_tab) {

    override fun setItemChildListener(helper: CEDViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout) //点击Item
    }

    override fun fillData(helper: CEDViewHolderHelper, position: Int, model: JSONObject) {
        val isSelect = model.optBoolean("isSelect", false)
        val textTitle = helper.getTextView(R.id.textTitle)
        val vCursor = helper.getView<View>(R.id.vCursor)
        textTitle.text = model.optString("tabTitle")

        if (isSelect) {
            textTitle.setTypeface(Typeface.DEFAULT,Typeface.BOLD)
            textTitle.setTextColor(Color.parseColor("#FF000000"))
            vCursor.visibility = View.VISIBLE
        } else {
            textTitle.setTypeface(Typeface.DEFAULT,Typeface.NORMAL)
            textTitle.setTextColor(Color.parseColor("#FF767676"))
            vCursor.visibility = View.INVISIBLE
        }
    }
}